home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Taifun
/
Taifun 007 (1987-02-15)(Ossowski, Stefan)(DE)(PD).zip
/
Taifun 007 (1987-02-15)(Ossowski, Stefan)(DE)(PD).adf
/
C Compiler
/
sieve.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-03-04
|
464b
|
30 lines
#define true 1
#define false 0
#define size 8190
#define sizepl 8191
char flags[sizepl];
main() {
int i,prime,k,count,iter;
printf("10 iterations\n");
for(iter=1;iter<= 10;iter++){
count=0;
for(i = 0; i<=size;i++)
flags[i]=true;
for(i=0;i <= size; i++){
if(flags[i]){
prime = i+i+3;
k=i+prime;
while(k<=size){
flags[k] = false;
k += prime;
}
count = count+1;
}
}
}
printf("\n%d primes\n",count);
}